#include <Comm/Include/LockableObject.h>

#include <iostream>

LockableObject::LockableObject(ISincronizable *object_to_sync)
{
    this->single_lock = new CSingleLock(object_to_sync->getCriticalSection());
}

LockableObject::~LockableObject()
{
    if (this->single_lock->IsLocked())
    {
        this->unlock();
    }
    delete this->single_lock;
}

void LockableObject::lock()
{
    this->single_lock->Lock();
}

void LockableObject::unlock()
{
    this->single_lock->Unlock();
}
 